﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.UI;

public class mulLimit : MonoBehaviour
{
    InputField inputField;

    private void Start()
    {
        inputField = GetComponent<InputField>();
    }

    public void onEditorEnded(string v)
    {
        try
        {
            int t = int.Parse(v);
            if (t % 3 != 0)
            {
                int c = 0;
                while (c < t)
                {
                    c += 3;
                }
                inputField.text = c.ToString();
            }
        }
        catch (Exception e)
        {
            sb.Append(e.Source + '\n' + e.Message + '\n' + e.StackTrace);
            Invoke("Clear", 5);
        }
    }

    public void Clear()
    {
        this.sb.Clear();
    }

    StringBuilder sb = new StringBuilder();
    private void OnGUI()
    {
        GUI.Label(new Rect((float)(Screen.width * 0.5 - 200), (float)(Screen.height * 0.5 - 150), 400, 300), sb.ToString());
    }
}
